// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   HistoricosAction.java

package org.fiel.struts.actions;

import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletRequest;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.fiel.commons.jdbc.*;
import org.fiel.persistence.InformacionPersistor;

// Referenced classes of package org.fiel.struts.actions:
//            FielAction

public class HistoricosAction extends FielAction
{

    public HistoricosAction()
    {
    }

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws Exception
    {
        String tipo = request.getParameter("tipo");
        String anio = request.getParameter("anio");
        String subtipo = request.getParameter("subtipo");
        String rol = obtenerRol(request);
        List listadoHistorico = obtenerHistorico(tipo, anio, subtipo, rol);
        request.getSession().setAttribute("listadoHistorico", listadoHistorico);
        return mapping.findForward("historico");
    }

    private List obtenerHistorico(String tipo, String anio, String subtipo, String rol)
    {
        Finder persistor = new InformacionPersistor();
        List constraints = new ArrayList();
        constraints.add(new Constraint("identipo", "=", new Integer(tipo)));
        constraints.add(new FunctionInstrConstraint("nivel", rol));
        constraints.add(new Constraint("nivel", "<>", new Integer(0)));
        if(anio != null)
            constraints.add(new FunctionYearConstraint("fechae", "=", new Integer(anio)));
        if(subtipo != null)
            constraints.add(new Constraint("idensubtipo", "=", subtipo));
        return persistor.FindAll(constraints);
    }
}
